<?php

class Captcha_model extends CI_Model {

    public function __construct() {
        parent::__construct();
    }

    public function get_captcha($info) {
        $query = $this->db->get_where('captcha', array('ip' => $info['ip']));
        return $query->result();
    }

    public function set_captcha($info) {
        $query = $this->db->get_where('captcha', array('ip' => $info['ip']));
        $capt = $query->result();

        $data = array(
            'word' => $info['word'],
            'time' => $info['time'],
        );

        if (count($capt) > 0) {
            $this->db->where('ip', $info['ip']);
            $this->db->update('captcha', $data);
        }
    }

}
